import {Component, Input, OnInit, ViewChild} from '@angular/core';
import { Service } from '../../server/server';
import { Pagination } from '../../public/serve/pcrudInfo';
import { ProductTypeTableComponent } from '../product-type/product-type-table/product-type-table.component';
import {RemoveTableService} from '../../public/serve/remove-table/remove-table.service';
declare var $: any;

@Component({
	selector: 'app-product-type',
	templateUrl: './product-type.component.html',
    styleUrls: ['./product-type.component.css']
})
export class ProductTypeComponent implements OnInit {
    public showTitle: number = 1;
	tableNumber: number = 0;
    @Input() searchData: any;
	public nodeSelect : any;
	right: any = {
        "systemProductType": {},
    };
	constructor( public removeTableService: RemoveTableService,private server: Service) {
		this.right = $.extend(this.right, server.getRight());
	}

	public isActive = this.server.isActive;

	ngOnInit() {

	}


	ngDoCheck() {

	}

	//导入table
	@ViewChild("table")
	table: ProductTypeTableComponent;

	// 表格
	public totalItems: number;
	ParentList(totalItems: number) {
		this.totalItems = totalItems;
	}

    ParentDetails(details: any) {
        this.details = details;
	}
	
	ParentAdd(e){

	}
	ParentEdit(e){

	}
	ParentDelete(e){
		
	}

    // 删除按钮
    isSelect: boolean = true;
    isSelectFromTableHandler(isSelect: boolean) {
        this.isSelect = isSelect;
    }
    details    : object;
	// 当前页（默认为第一页）
	public pageNumber: number = 1;

	// 每页显示多少条数据（默认每页显示20条）
	public pageSize: number = 20;
	// id
	public id: string = '0';
	// 分页
	public pagination: Pagination;
	isLoadTableFromPaginationHandler(pagination: Pagination) {
		this.pagination = pagination;

		this.pageNumber = this.pagination[0].pageNumber;
		this.pageSize = this.pagination[0].pageSize;
		this.id = this.pagination[0].id;

		this.tableNumber = (pagination[0].pageNumber - 1) * pagination[0].pageSize;

		this.table.getTabList(
			this.pageNumber,
			this.pageSize,
			this.status,
			this.searchData,
            this.nodeSelect.categoryId
		);
	}

	//查询条件
	public queryCriteria: string = '';
	public status: number = 0;

	selectNode(val){
		this.nodeSelect = val;
        this.table.getTabList(1, 20, '0', this.searchData,this.nodeSelect.categoryId);
	}

	//查询
	search() {
        this.table.getTabList(1, 20, '0', this.searchData,this.nodeSelect.categoryId);
	}
	//监听
	changesearch() {
		this.search();
	}

}